package com.fafu.rbac.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fafu.rbac.domain.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("""
        SELECT tb_role.id, tb_role.`code`
        from tb_role
        INNER JOIN tb_user_role
        ON tb_role.id = tb_user_role.role_id
        where tb_user_role.user_id = ${userId}
    """)
    List<Role> selectRoleByUserId(@Param("userId") Long userId);
}